class Solution:    
    def __init__(self):
        self.stack1=[]
        self.stack2=[]
    def push(self, node):
        self.stack1.append(node);
    def pop(self):
        if self.stack2 == []:
            self.stack2 = list(reversed(self.stack1))
            self.stack1 = []
        return self.stack2.pop()